home *** CD-ROM | disk | FTP | other *** search
/ PC Media 2 / PC MEDIA CD02.iso / share / udos / drvdir / drvdir.doc < prev   
Encoding:
Text File  |  1991-01-26  |  4.9 KB  |  119 lines

  1.  
  2. ______DRVDIR                                                            Ver. 2.00
  3.  
  4.  
  5.  
  6. Purpose: Batch file utility for use with SWEEP.COM & similar.  DrvDir re-
  7.          turns (separately) the current path-&-directory and both the cur-
  8.                                               ______         rent drive letter spec and the drive number.
  9.  
  10. Format:     DRVDIR [F] [R]
  11.  
  12. Remarks: Run without parameters DrvDir puts the drive letter (with colon;
  13.          e.g. D:) in DRV.  In another environment variable, CUR, it puts
  14.          the current path\directory (e.g. \TP\PROG).  Finally, it puts the
  15.                ______         drive number in the DOS Errorlevel.  If anything goes wrong, (usu-
  16.          ally because you're out of environment space), the Errorlevel re-
  17.          turns 255.  The two options modify this behavior as follows
  18.  
  19.          F  (or -F or /F) changes what DrvDir returns in the Errorlevel.
  20.             Instead of the drive number, you get the number of files in the
  21.             directory (up to 254) or 255 to mean failure.  You might need
  22.             to know this if you're using a copy utility like Tall Tree's
  23.             JET.COM, which needs to be told explicitly whether to enlarge
  24.             the directory.
  25.  
  26.          R  (or -R or /R) changes what's put in the CUR environment vari-
  27.             able: if the current directory is the root directory, CUR will
  28.             carry the value "ROOT" without a preceding backslash.  (A di-
  29.             rectory that was really named "ROOT" would be reported as
  30.             "\ROOT".)  You may need to use this if you're using a version
  31.             of DOS like 2.1, which can't handle an empty environment vari-
  32.             able.[1]
  33.  
  34.          Why extract and stash this information?  A batch file that sweeps
  35.          through a set of directories using a utility like SWEEP.COM (one
  36.          of PC Magazine's) may need to know what the current directory is.
  37.          Say, you have a Bernoulli on drive E: and you want to copy every-
  38.          thing in each directory of the default drive to the corresponding
  39.          directory on E:.  Simplified, here's a way to do it.  First make a
  40.          batch file STASH.BAT:
  41.  
  42.             DrvDir
  43.             copy %DRV%%CUR%\*.* E:%CUR%
  44.  
  45.          Then, to back up the whole drive, go to the root directory of your
  46.          hard disk, and command: SWEEP STASH
  47.  
  48.          Ordinarily, drive letters are assigned in order of the drive num-
  49.          bers, drive 0 is called A:, 1 is B:, etc.  With recent versions of
  50. -----------
  51.  
  52.  
  53. 1. I've checked this point under DOS 2.10, which can't handle empty vari-
  54.    ables, and DOS 3.3, which can.  I can't speak for other versions.  To
  55.    test it for yourself, go to the root directory and run a little batch
  56.    file:
  57.  
  58.             echo off
  59.             DRVDIR
  60.             echo %CUR%
  61. ______DRVDIR 2.00                                                          Page 2
  62.  
  63.  
  64.          DOS, however, it is possible to create logical drives in such a
  65.          way that the letters don't correspond with the numbers.  For this
  66.          reason, DrvDir returns both.[2] Ordinarily, you can use %DRV%%CUR%
  67.          to identify the current drive & directory.  If you've done tricky
  68.          things with your drives and the letters come out wrong, you can
  69.          fall back on the errorlevel.  You'll have to work it out with a
  70.          series of IF ERRORLEVEL statements.  Instead of
  71.  
  72.             drvdir
  73.             copy %DRV%%CUR%\*.* E:%CUR%\
  74.  
  75.          you'd have to use:
  76.  
  77.             drvdir
  78.             if errorlevel 0 if not errorlevel 1 copy A:%CUR%\*.* E:%CUR%
  79.             if errorlevel 1 if not errorlevel 2 copy B:%CUR%\*.* E:%CUR%
  80.             etc.
  81.  
  82.                                         _____         Notice, by the way that DrvDir never ends the path spec with a
  83.                             ______         backslash (\), and always puts a backslash before a subdirectory
  84.          name.  Laying aside the R option, %CUR%!==! will be true in the
  85.          root directory and false in any other.  Unfortunately, the bug in
  86.          DOS 2.1 ruins this.  Since that version of DOS won't return an
  87.          empty variable, even in the root directory (you get things like
  88.          CUR%!) %CUR%!==! will return false.  If your batch file may be run
  89.          under DOS 2.1, the R option at least gets you an unmistakeable
  90.          sign that this is the root directory, so you can do clumsy things
  91.          like:
  92.  
  93.             if %CUR%!==ROOT!  copy A:\*.* E:\
  94.             if not %CUR%!==ROOT!  copy A:%CUR%\*.* E:%CUR%\
  95.  
  96.  
  97.  
  98.                                                     R. N. Wisan, June, 1990
  99.                                           37 Clinton St., Oneonta, NY 13820
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. -----------
  115.  
  116.  
  117. 2. Well, I hope it's the "physical" drive number.  I'd appreciate word from
  118.    anybody whose logical and physical drives don't match.  Tell me whether
  119.    this works.